using System;
using UnityEngine;

public class EnemyMovement : MonoBehaviour
{

    [Header("Elements")] 
    private Player player;

    
    [Header("Settings")] 
    [SerializeField] private float moveSpeed;

    
  

    void Update()
    {
        // 跟随玩家
        if (player != null)
            FollowPlayer();
    }

    public void StorePlayer(Player player)
    {
        this.player = player;
    }

    private void FollowPlayer()
    {
        Vector3 position = transform.position;
        Vector3 direction = (player.transform.position - position).normalized;
        Vector3 targetPosition = position + direction * (moveSpeed * Time.deltaTime);

        transform.position = targetPosition;
    }

    

   
    
   


}
